import 'package:flutter/material.dart';
import 'package:ytbusiness/config/yt_theme.dart';
import 'package:ytbusiness/utils/screen_adaptation.dart';


//选则类型组件
class CheckType extends StatefulWidget {
  final String title; //选项名
  final int index; //当前索引
  final int checkIndex;//当前选中索引
  final Function check;//回调

  const CheckType({Key key, this.title, this.index, this.checkIndex, this.check}) : super(key: key);
  @override
  _CheckTypeState createState() => _CheckTypeState();
}

class _CheckTypeState extends State<CheckType> {
  @override
  Widget build(BuildContext context) {
    return GestureDetector(
      onTap: ()=> widget.check(),
      child: Container(
        padding: EdgeInsets.only(top: setWidth(6),bottom: setWidth(6),left: setWidth(11),right: setWidth(11)),
        decoration: BoxDecoration(
            color: widget.checkIndex == widget.index ?Color(0xffF5FFFF):Color(0xffF5F5F5),
            border: Border.all(color: widget.checkIndex == widget.index ?YTTheme.theme:Color(0xffF5F5F5),width: setWidth(0.5)),
            borderRadius: BorderRadius.circular(2)
        ),
        child: Text(widget.title,style: TextStyle(color: widget.checkIndex == widget.index ?YTTheme.theme:Color(0xff989898),fontSize: setSp(14)),),
      ),
    );
  }
}
